Socket
Socket
Sign inDemoInstall

@opentelemetry/context-base

Package Overview
Dependencies
0
Maintainers
5
Versions
27
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @opentelemetry/context-base

OpenTelemetry Base Context Manager


Version published
Weekly downloads
120K
decreased by-1.45%
Maintainers
5
Install size
28.9 kB
Created
Weekly downloads
 

Package description

What is @opentelemetry/context-base?

@opentelemetry/context-base is a package that provides a base implementation for context management in OpenTelemetry. It allows for the creation, management, and propagation of context across different parts of an application, which is essential for distributed tracing and telemetry data collection.

What are @opentelemetry/context-base's main functionalities?

Creating a Context

This feature allows you to create a new context instance. Contexts are used to store and propagate data across different parts of an application.

const { BaseContext } = require('@opentelemetry/context-base');
const context = new BaseContext();
console.log(context);

Setting and Getting Values in Context

This feature allows you to set and get values in a context. This is useful for storing data that needs to be accessed across different parts of an application.

const { BaseContext } = require('@opentelemetry/context-base');
const context = new BaseContext();
const key = 'exampleKey';
const value = 'exampleValue';
const updatedContext = context.setValue(key, value);
console.log(updatedContext.getValue(key)); // Outputs: 'exampleValue'

Context Propagation

This feature demonstrates how context can be propagated across different functions or parts of an application. This is essential for maintaining state and data consistency in distributed systems.

const { BaseContext } = require('@opentelemetry/context-base');
const context = new BaseContext();
const key = 'exampleKey';
const value = 'exampleValue';
const updatedContext = context.setValue(key, value);
function someFunction(ctx) {
  console.log(ctx.getValue(key)); // Outputs: 'exampleValue'
}
someFunction(updatedContext);

Other packages similar to @opentelemetry/context-base

Changelog

Source

0.5.2

Released 2020-03-27

:rocket: (Enhancement)

  • opentelemetry-exporter-prometheus, opentelemetry-metrics
    • #893 Metrics: Add lastUpdateTimestamp associated with point (@mayurkale22)
  • opentelemetry-tracing
  • opentelemetry-api, opentelemetry-tracing
    • #889 feat: start a root span with spanOptions.parent = null (@dyladan)

:bug: (Bug Fix)

  • opentelemetry-core, opentelemetry-propagator-jaeger
  • opentelemetry-context-base, opentelemetry-core, opentelemetry-plugin-document-load, opentelemetry-plugin-user-interaction, opentelemetry-web
    • #906 chore: fixing documentation for web tracer provider, fixing examples … (@obecny)
  • Other

:books: (Refine Doc)

  • opentelemetry-context-base, opentelemetry-core, opentelemetry-plugin-document-load, opentelemetry-plugin-user-interaction, opentelemetry-web
    • #906 chore: fixing documentation for web tracer provider, fixing examples … (@obecny)

Committers: 4

Readme

Source

OpenTelemetry Base Context Manager

Gitter chat NPM Published Version dependencies devDependencies Apache License

This package provides the ContextManager interface (which is used by concrete implementations) and a no-op implementation (which is used internally when no context propagation is defined). It's intended for use both on the server and in the browser.

What is a Context Manager ?

To understand why they exists, we'll need to understand how Javascript works: when you make native function call (networks, setInterval etc) you generally call C++ code that will later callback your own code.

A common issue when tracing a request in javascript is to link the function that have made the native call to the callback that the native code called when the response is there. Imagine you want to track for which user you made the request, you need some sort of "context/context aware storage".

ContextManager's aim to offer exactly that, it's API offer to store an object in the current context (with()) and if needed, bind() to a specific function call to find it back when the callback fire, which can later get retrieved using active().

This package only include the interface and a Noop implementation, for more information please see the async-hooks based ContextManager for NodeJS.

License

Apache 2.0 - See LICENSE for more information.

Keywords

FAQs

Last updated on 27 Mar 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc